#include "stdafx.h"


#ifndef __CGLOBAL__
#define __CGLOBAL__

class CGlobe
{
public:
	// for AR marker recognition
	int		imgWidth, imgHeight;
	char	*szCameraParamFName;
	char	*szPattFName;
	char	*szVConfFName;
	Matrix	g_matPlanarProjection;
	int		windowWidth, windowHeight;

	// model scale
	double  fScale;


	// tell the other thread to stop
	bool	bStop;


	// for thread synchronism
	HANDLE			 hThreadOK;
	HANDLE			 hRecogDeal;
	HANDLE			 hStop;


	// hear sound?
	bool bHearSound;

	// points for ray, according to the camshift results
	// these points are in the world coordinates
	double wxDir, wyDir, wzDir, wxOri, wyOri, wzOri;

	int windowZoom;

	bool bTouch, bNormalChanged, bDance;

public:
	CGlobe()
	{
		fScale = 1.6;
		bNormalChanged = bStop = bDance = false;
		imgWidth = imgHeight = windowHeight = windowWidth = 0;

		// for AR 
		char strVC[] = "..\\data\\WDM_camera_flipV.xml";
		int i = sizeof(strVC);
		szVConfFName = new char [sizeof(strVC) + 1];
		memcpy(szVConfFName, strVC, sizeof(strVC) + 1);

		imgWidth = imgHeight = 0;

		char strCN[] = "..\\data\\camera_para.dat";
		szCameraParamFName = new char [sizeof(strCN) + 1];
		memcpy(szCameraParamFName, strCN, sizeof(strCN) + 1);

		char strPN[] = "..\\data\\patt.kanji";
		szPattFName = new char [sizeof(strPN) + 1];
		memcpy(szPattFName, strPN, sizeof(strPN) + 1);

		// for thread synchronism
		hThreadOK = CreateEvent(NULL, FALSE, FALSE, NULL);
		hRecogDeal = CreateEvent(NULL, FALSE, FALSE, NULL);

		// hear sound?
		bHearSound = false;

		// for showing image
		hStop = CreateEvent(NULL, FALSE, FALSE, NULL);

		// points for ray, according to the camshift results
		wxDir = wyDir = wzDir = wxOri = wyOri = wzOri = 0.0;

		bTouch = false;
	}

	~CGlobe()
	{
		if (szVConfFName != NULL)
		{
			delete [] szVConfFName;
		}

		if (szCameraParamFName != NULL)
		{
			delete [] szCameraParamFName;
		}

		if (szPattFName != NULL)
		{
			delete [] szPattFName;
		}


		CloseHandle(hStop);
		CloseHandle(hThreadOK);
		CloseHandle(hRecogDeal);
	}

};

#endif
